package cn.iocoder.yudao.module.system.controller.app.videostore;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.videostore.VideoStoreUtil;
import cn.iocoder.yudao.module.system.videostore.dto.product.AddProductDTO;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "视频号小店")
@RestController
@RequestMapping("/system/videoStore")
@Slf4j
public class VideoStoreController {

    @Resource
    private VideoStoreUtil videoStoreUtil;

    @GetMapping("/getVideoStoreAccessToken")
    @Operation(summary = "获取调用凭据")
    public CommonResult<String> getVideoStoreAccessToken() {
        return success(videoStoreUtil.getVideoStoreAccessToken());
    }

    @GetMapping("/uploadVideoStoreImg")
    @Operation(summary = "上传图片")
    public CommonResult<String> uploadVideoStoreImg(@RequestParam("httpURL") String httpURL) {
        return success(videoStoreUtil.uploadVideoStoreImg(httpURL));
    }

    @GetMapping("/videoStoreCategoryDetail")
    @Operation(summary = "根据三级类目ID获取类目的相关信息")
    public CommonResult<JSONObject> videoStoreCategoryDetail(@RequestParam("cat_id") String cat_id) {
        return success(videoStoreUtil.videoStoreCategoryDetail(cat_id));
    }

    @PostMapping("/addVideoStoreProduct")
    @Operation(summary = "添加商品")
    public CommonResult<String> addVideoStoreProduct(@RequestBody AddProductDTO addProductDTO) {
        return success(videoStoreUtil.addVideoStoreProduct(addProductDTO));
    }

}
